from PyQt6.QtCore import QUrl
from PyQt6.QtWebEngineWidgets import QWebEngineView
from PyQt6.QtWidgets import QMainWindow, QApplication

import sys


class WebEngineView(QMainWindow):
    def __init__(self, url: str, title: str):
        super(WebEngineView, self).__init__()
        self.setWindowTitle(title)
        self.resize(960, 540)
        # 新建一个QWebEngineView()对象
        self.qwebengine = QWebEngineView(self)
        # 设置网页在窗口中显示的位置和大小
        self.qwebengine.setGeometry(0, 0, 960, 540)
        # 在QWebEngineView中加载网址
        self.qwebengine.load(QUrl(url))


if __name__ == '__main__':
    app = QApplication(sys.argv)
    # ui = WebEngineView("https://www.bilibili.com/video/BV1vx411E7Mb", "Title")
    ui = WebEngineView("http://localhost:3333/test/multimedia#013800138999-2", "Title")
    ui.show()
    app.exec()
